/*
    This file is part of Emu.

    Emu is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Emu is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public License
    along with Emu.  If not, see <http://www.gnu.org/licenses/>. */
#ifndef ESEARCHBAR_H
# define ESEARCHBAR_H

# include <QCheckBox>
# include <QLineEdit>
# include <QTextCharFormat>
# include <QTextEdit>

class ESearchBar : public QWidget
{
    Q_OBJECT

public:
    ESearchBar(QTextEdit *);

    QLineEdit *searchWindow() { return _searchWindow; }
    void setCurrent(bool c) { _current = c; }

public slots:
    void catchSearchPrevious();
    void catchSearchNext();

private:
    QTextEdit *_recvWindow;

    bool _current;
    bool _canRedo;
    bool _canUndo;
    bool _canCutCopy;
    bool _lastSearchWasValid;
    QColor _searchWasFoundBackColor;
    QColor _searchWasFoundForeColor;
    QColor _searchNotFoundBackColor;
    QColor _searchNotFoundForeColor;
    QString _lastSearchText;
    QLineEdit *_searchWindow;
    QCheckBox *_caseSensitiveCheck;
    QTextCharFormat _highlightFormat;

    void doSearch(bool);
    void updateSearchPalette(bool);

private slots:
    void catchSearchSelectionChanged();
    void catchSearchTextChanged(QString);

Q_SIGNALS:
    void searchWindowCutCopyAvailable(bool);
    void searchWindowRedoAvailable(bool);
    void searchWindowUndoAvailable(bool);
};

#endif
